package org.ala.tiktools.generator.mybatis.creator.order_by;

import freemarker.template.TemplateException;
import org.ala.tiktools.generator.mybatis.config.info.Part;
import org.ala.tiktools.generator.mybatis.creator.AbstractCreator;
import org.ala.tiktools.generator.mybatis.creator.dao.DaoInfo;
import org.ala.tiktools.generator.mybatis.creator.entity.EntityInfo;
import org.ala.tiktools.generator.mybatis.creator.query.QueryInfo;
import org.ala.tiktools.generator.mybatis.dbinfo.TableInfo;
import org.ala.tiktools.generator.mybatis.tools.Tools;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ala
 * @date 2025-01-13 15:33
 */
public class OrderByCreator extends AbstractCreator {

    public OrderByInfo create(Part p, TableInfo t, EntityInfo e) throws TemplateException, IOException {
        OrderByInfo ob = OrderByInfo.build(p, t, e);
        Map<String, Object> dataMeta = new HashMap<>();
        dataMeta.put("ob", ob);

        String out = ob.getPkg();
        out = this.getOutRootPath() + out.replaceAll("\\.", "/");
        Tools.existsAndMakeDirs(out);
        out = out + "/" + ob.getClassName() + ".java";

        output("OrderBy.ftl", dataMeta, out);

        System.out.println("生成OrderBy类. path:" + out);
        return ob;
    }
}
